home *** CD-ROM | disk | FTP | other *** search
/ Champak 106 / Vol 106.iso / games / scorched.swf / scripts / frame_116 / DoAction_2.as < prev    next >
Encoding:
Text File  |  2010-04-12  |  3.1 KB  |  145 lines

  1. function jetpacing()
  2. {
  3.    var _loc1_ = this;
  4.    lastbx = bx;
  5.    lastby = by;
  6.    bombtrailcount++;
  7.    if(by < 0)
  8.    {
  9.       _loc1_.misslefollow._x = bx;
  10.    }
  11.    else
  12.    {
  13.       _loc1_.misslefollow._x = -10;
  14.    }
  15.    if(xmove > 0)
  16.    {
  17.       rightv = xmove;
  18.    }
  19.    else
  20.    {
  21.       leftv = Math.abs(xmove);
  22.    }
  23.    upv = temppower * Math.sin(radian);
  24.    adjustx = 45 * Math.cos(radian);
  25.    adjusty = 8 + 45 * Math.sin(radian);
  26.    temppower -= gravity;
  27.    upv = temppower * Math.sin(radian);
  28.    if(rightv > 0)
  29.    {
  30.       rightv += windamount;
  31.       if(rightv < 0)
  32.       {
  33.          leftv = Math.abs(rightv);
  34.          rightv = 0;
  35.       }
  36.    }
  37.    if(leftv > 0)
  38.    {
  39.       leftv -= windamount;
  40.       if(leftv < 0)
  41.       {
  42.          rightv = Math.abs(leftv);
  43.          leftv = 0;
  44.       }
  45.    }
  46.    bx += rightv;
  47.    bx -= leftv;
  48.    by += upv;
  49.    if(bx > 780)
  50.    {
  51.       bx = 779;
  52.       leftv = rightv;
  53.       rightv = 0;
  54.    }
  55.    if(bx < 20)
  56.    {
  57.       bx = 21;
  58.       rightv = leftv;
  59.       leftv = 0;
  60.    }
  61.    if(by > 560)
  62.    {
  63.       by = 560;
  64.       hity = 560;
  65.       lastbx = undefined;
  66.       action = "player stops jetpacing";
  67.    }
  68.    hitarraynumlow = Math.floor(bx / landdetail);
  69.    hitarraynumhigh = Math.ceil(bx / landdetail);
  70.    l1y = landarray[hitarraynumlow];
  71.    l2y = landarray[hitarraynumhigh];
  72.    l2x = hitarraynumhigh * landdetail;
  73.    l1x = hitarraynumlow * landdetail;
  74.    bombm = (by - oby) / (bx - obx);
  75.    bombb = by - bombm * bx;
  76.    landm = (l1y - l2y) / (l1x - l2x);
  77.    landb = l1y - landm * l1x;
  78.    hitx = (bombb - landb) / (landm - bombm);
  79.    hity = bombm * hitx + bombb;
  80.    x = hitx;
  81.    y = hity;
  82.    r = bx;
  83.    s = obx;
  84.    t = by;
  85.    u = oby;
  86.    hitline = -10;
  87.    if(hitx < Infinity && hitx > - Infinity && hity < Infinity && hity > - Infinity)
  88.    {
  89.       if(hitx >= bx && hitx <= obx || hitx >= obx && hitx <= bx && (hity >= by && hity <= oby) || hity >= oby && hity <= by)
  90.       {
  91.          hitline = 1;
  92.       }
  93.       if(hitx >= l1x && hitx <= l2x || hitx >= l2x && hitx <= l1x && (hity >= l1y && hity <= l2y) || hity >= l2y && hity <= l1y)
  94.       {
  95.          hitline++;
  96.       }
  97.       if(hitline > 1)
  98.       {
  99.          action = "player stops jetpacing";
  100.       }
  101.    }
  102.    hitarraynum = Math.floor(bx / landdetail);
  103.    hitloc = landarray[hitarraynum];
  104.    if(by >= hitloc)
  105.    {
  106.       hitx = hitarraynum * landdetail;
  107.       hity = hitloc - 40;
  108.       action = "player stops jetpacing";
  109.    }
  110.    _loc1_.jetpac._x = bx;
  111.    _loc1_.jetpac._y = by;
  112.    if(bx < lastbx)
  113.    {
  114.       jetpac._xscale = -100;
  115.       jetd = -100;
  116.    }
  117.    if(bx > lastbx)
  118.    {
  119.       jetpac._xscale = 100;
  120.       jetd = 100;
  121.    }
  122.    a = (bx - lastbx) / (by - lastby);
  123.    b = - Math.asin(a) * 180 / 3.141592653589793;
  124.    if(b < -30)
  125.    {
  126.       b = -30;
  127.    }
  128.    if(b > 30)
  129.    {
  130.       b = 30;
  131.    }
  132.    jetpac._rotation = b;
  133.    bombtrailcount++;
  134.    if(bombtrailcount > 5)
  135.    {
  136.       bombtrailcount = 0;
  137.       landscape.attachMovie("jetpactrail","b" + bombt,bombt);
  138.       bombt++;
  139.       if(bombt > 500)
  140.       {
  141.          bombt = 400;
  142.       }
  143.    }
  144. }
  145.